package com.rockgle.reader;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class PreferenceMonitor {
	public static final String PREFERENCE_FILENAME = "AppPrefs";
	public static final String PREF_SHOWONLYUNREAD = "showonlyunread";
	public static final String PREF_USESERVICE = "useService";
	public static final String PREF_REFRESHRATESERVICE = "refreshRateService";
	
	
	private static boolean showOnlyUnreadPreference;
	private static boolean useService;
	private static String refreshRateService;
	
	public static boolean getOnlyUnread(){
		getPrefs();
		return showOnlyUnreadPreference;
	}
	
	public static boolean getUseService(){
		getPrefs();
		return useService;
	}
	
	public static String getRefreshRateService(){
		getPrefs();
		return refreshRateService;
	}
	
	public static void getPrefs(){
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(CustomApplication.getContext());
		showOnlyUnreadPreference = prefs.getBoolean(PreferenceMonitor.PREF_SHOWONLYUNREAD, false);
		useService = prefs.getBoolean(PreferenceMonitor.PREF_USESERVICE, false);
		refreshRateService = prefs.getString(PreferenceMonitor.PREF_REFRESHRATESERVICE, "3600000");
	}
	
	public static void setUseService(boolean bool){
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(CustomApplication.getContext());
		SharedPreferences.Editor editor = prefs.edit();
		editor.putBoolean(PREF_USESERVICE, bool);
		editor.commit();
	}
}
